package cn.zzp.controller;

import cn.zzp.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName OrderController
 * @Description
 * @Author 祝志鹏
 * @Date 2022/8/18 19:09
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/getUser/{id}")
    public User getUser(@PathVariable("id") Long id) {

        // 调用user接口发送请求，获取对象
        String url = "http://user-server/user/getById/" + id;
        return restTemplate.getForObject(url, User.class);
    }

}
